#include ("/_includes/_layout.html")
#@layout("会员卡", "wxmall,点步科技", "Wxmall社区","wxmall") 
#define content()
<div class="wrapper wrapper-content">
	<div class="content-tabs">
		<nav class="page-tabs J_menuTabs">
	       <div class="page-tabs-content">
		       <a href="#(webctx)/customer/members" class="J_menuTab">会员</a>
		       <a href="#(webctx)/memberRank" class="J_menuTab">会员等级</a>
		       <a href="#(webctx)/card" class="J_menuTab active">会员卡</a>
	       </div>
	   	</nav>
	</div>
	<div id="tableList" class="content ibox-content">
		<div class="panel-body">
			<div style="float: left; margin-right: 20px;"><a href="#(webctx)/card/set" class="btn btn-success">新建会员卡</a></div>
			<div id="pager" class="jqpager" style="margin-bottom: 1px;"></div>		
		</div>
		<table id="mainTable" class="table table-striped table-bordered bootstrap-datatable datatable" border="0">
		  <thead>
			  <tr>
				<th><input type="checkbox" id="all" title="全选/反选" style="margin-right: 4px; vertical-align: middle;"/></th>
				<th><span style="vertical-align: middle;">&nbsp;&nbsp;卡券名称</span></th>
				<th>商户</th>
				<th>状态</th>
				<th>库存</th>
				<th>有效期</th>
				<th>操作</th>
			  </tr>
		  </thead>   
		  <tbody class="itemsLotGrid"></tbody>
	  	</table>
	</div>
</div>
#end
<!-- html 模板文件 -->
<script type="text/template" id="item_table_tr_tpl">
		<tr class="package">
			<td>
				<input type="checkbox" class="commchk" id="checkbox_{id}" style="margin-right: 4px; vertical-align: middle;"/>
				<input type="hidden" value="{id}"/>
			</td>
			<td>{cardName}</td>
			<td>{brandName}</td>
			<td>{statusCn}</td>
			<td>总库存：{totalQuantity}<br/>剩余：{quantity}</td>
			<td>{dateInfo}</td>
			<td>
				&nbsp;<a id="edit_{id}" href="javascript:void(0)">编辑</a>
				<!-- &nbsp;<a id="del_{id}" href="javascript:void(0)">删除</a> -->
				&nbsp;<a id="tf_{cardId}" href="javascript:void(0)">投放</a>
			</td>
		</tr>
</script>
<script type="text/template" id="table_noresult_tr_tpl">
	<tr class="package"><td colspan="7" class="center">没有结果集 &nbsp;<a href="#(webctx)/card/set">去创建</a></td></tr>
</script>
<script type="text/javascript">
var qname = "";
$(document).ready(function() {
	var params = {};
	var table = new obz.TableView("pager", obz.ctx + "/card/list", params, function(resp){
		$(".itemsLotGrid").empty();
		var dataList = resp.list || {};
		if(dataList.length>0){
			for(var i=0;i<dataList.length;i++){
				var _row = dataList[i];
				var trHtml = obz.dataTemplate4obj($("#item_table_tr_tpl").html(), _row);
				$(".itemsLotGrid").append(trHtml);
			}
			//初始化checkbox点击事件
			TBatch.checkCheckbox();
			TBatch.initCheckboxClick();
			TBatch.initOptEvent(TableOpt.init());
		}else{
			$(".itemsLotGrid").append($("#table_noresult_tr_tpl").html());
		}
	});
	table.init();

	var TableOpt = {
		edit : function(param){
			var id = param[1];
			location.href = "#(webctx)/card/set/?id=" + id;
			return false;
		},	
		putin : function(param){
			var dialog = BootstrapDialog.show({
				size: BootstrapDialog.SIZE_LARGE,
				title: "投放会员卡",
		        message: $('<div></div>').load("#(webctx)/card/cput/?id="+param[1])
		    });
			return false;
		},	
		init : function(){
			var optArray = new Array();
			optArray.push(this.edit);
			optArray.push(this.putin);
			return optArray;
		}
	}
	
	$("#myqueryBtn").click(function(){
		params.qname = $("#q_pond_txt").val();
		table.init();
	});
});
</script>